/*
 * NumberUtil.java
 * Copyright (c) 2014, 2019, Kiri. 
 * All rights reserved.
 */
package com.onesalt.utils;

import java.text.NumberFormat;

/**
 * 
 *
 * @author kiri
 * @date 2015年4月30日
 * @version 1.0
 */
public class NumberUtil {
	
	public static String format(Number number, final int minIntegerDigits) {
		if (number == null) {
			number = 0;
		}
		NumberFormat format = NumberFormat.getInstance();
		format.setMinimumIntegerDigits(minIntegerDigits);
		format.setGroupingUsed(false);
		return format.format(number.longValue());
	}

	public static String format(Number number, final int minIntegerDigits, final int maxIntegerDigits) {
		if (number == null) {
			number = 0;
		}
		NumberFormat format = NumberFormat.getInstance();
		format.setMinimumIntegerDigits(minIntegerDigits);
		format.setMaximumIntegerDigits(maxIntegerDigits);
		format.setGroupingUsed(false);
		return format.format(number.longValue());
	}
}
